// 帮助中心
import request from '@/utils/request1'
// 查询帮助类型
function helpTypeList(query) {
  return request({
    url: '/logistics/helpType/getList',
    method: 'get',
    params: query
  })
}
// 新增帮助类型
export function addHelpType(data) {
  return request({
    url: '/logistics/helpType',
    method: 'post',
    data: data
  })
}
//   修改帮助类型
export function updateHelpType(data) {
  return request({
    url: '/logistics/helpType',
    method: 'put',
    data: data
  })
}
// 删除帮助类型
export function delHelpType(userId) {
  return request({
    url: '/logistics/helpType/' + userId,
    method: 'delete'
  })
}
//   获取帮助类型详细信息
export function gethelpTypeDetail(roleId) {
  return request({
    url: '/logistics/helpType/' + roleId,
    method: 'get'
  })
}
//   获取帮助中心详细信息 ===================================================================
export function gethelpCenterDetail(roleId) {
  return request({
    url: '/logistics/helpCenter/' + roleId,
    method: 'get'
  })
}
// 查询帮助中心列表
export function helpCenterList(query) {
  return request({
    url: '/logistics/helpCenter/list',
    method: 'get',
    params: query
  })
}
// 新增帮助中心
export function addHelpCenter(data) {
  return request({
    url: '/logistics/helpCenter',
    method: 'post',
    data: data
  })
}
//   修改帮助中心
export function updateHelpCenter(data) {
  return request({
    url: '/logistics/helpCenter',
    method: 'put',
    data: data
  })
}
//   批量修改帮助中心
export function helpBatchUpdateStatus(query) {
  return request({
    url: '/logistics/helpCenter/batchUpdateStatus',
    method: 'put',
    params: query,
    paramsSerializer: (params) => {
      return Object.keys(params)
        .map((key) => {
          if (Array.isArray(params[key])) {
            // 将数组元素转换为 idList=... 的形式
            return params[key].map((value) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join('&')
          }
          return `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`
        })
        .join('&')
    }
  })
}
// 删除帮助中心
export function delHelpCenter(userId) {
  return request({
    url: '/logistics/helpCenter/' + userId,
    method: 'delete'
  })
}
// 新增司机信息 ========================================================================
export function addDriver(data) {
  return request({
    url: '/logistics/driver',
    method: 'post',
    data: data
  })
}
//   修改司机信息
export function updateDriver(data) {
  return request({
    url: '/logistics/driver',
    method: 'put',
    data: data
  })
}
// 删除司机
export function delDriver(userId) {
  return request({
    url: '/logistics/driver/' + userId,
    method: 'delete'
  })
}

// 修改司机启用状态
export function setDriverEditEnabled(data) {
  return request({
    url: '/logistics/driver/editEnabled/' + data.ids + '/' + data.isEnabled,
    method: 'put'
  })
}
const obj = {
  helpTypeList,
  addHelpType,
  updateHelpType,
  delHelpType,
  gethelpTypeDetail,
  gethelpCenterDetail,
  helpCenterList,
  addHelpCenter,
  updateHelpCenter,
  helpBatchUpdateStatus,
  delHelpCenter,
  updateDriver,
  delDriver,
  setDriverEditEnabled
}
export default obj
